Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
	''' <summary>
	''' Strongly-typed collection for the TempImagesFile class.
	''' </summary>
	<Serializable> _
	Public Partial Class TempImagesFileCollection 
	Inherits ActiveList(Of TempImagesFile, TempImagesFileCollection)
	    Public Sub New()
		End Sub
	End Class
	''' <summary>
	''' This is an ActiveRecord class which wraps the TempImagesFile table.
	''' </summary>
	<Serializable> _
	Public Partial Class TempImagesFile 
	Inherits ActiveRecord(Of TempImagesFile)
		#Region ".ctors and Default Settings"
		
		Public Sub New()
			SetSQLProps()
			InitSetDefaults()
			MarkNew()
		End Sub
		
		Public Sub New(ByVal useDatabaseDefaults As Boolean)
			SetSQLProps()
			If useDatabaseDefaults = True Then
				ForceDefaults()
			End If
			MarkNew()
		End Sub
		Public Sub New(ByVal keyID As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByKey(keyID)
		End Sub
		Public Sub New(ByVal columnName As String, ByVal columnValue As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByParam(columnName,columnValue)
		End Sub
		Private Sub InitSetDefaults()
			SetDefaults()
		End Sub
		
		Protected Shared Sub SetSQLProps()
			GetTableSchema()
		End Sub
		#End Region
		
		#Region "Schema and Query Accessor"
		
		Public Shared ReadOnly Property Schema() As TableSchema.Table
			Get
				If BaseSchema Is Nothing Then
					SetSQLProps()
				End If
				Return BaseSchema
			End Get
		End Property
		Private Shared Sub GetTableSchema()
			If (Not IsSchemaInitialized) Then
				'Schema declaration
				Dim schema As TableSchema.Table = New TableSchema.Table("TempImagesFile", TableType.Table, DataService.GetInstance("ClubStarterKitData"))
				schema.Columns = New TableSchema.TableColumnCollection()
				schema.SchemaName = "dbo"
				'columns
				
                
                Dim colvarId As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarId.ColumnName = "ID"
                colvarId.DataType = DbType.Int32
                colvarId.MaxLength = 0
                colvarId.AutoIncrement = true
                colvarId.IsNullable = false
                colvarId.IsPrimaryKey = true
                colvarId.IsForeignKey = false
                colvarId.IsReadOnly = false
                
                
                schema.Columns.Add(colvarId)
                
                Dim colvarFilename As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarFilename.ColumnName = "Filename"
                colvarFilename.DataType = DbType.String
                colvarFilename.MaxLength = -1
                colvarFilename.AutoIncrement = false
                colvarFilename.IsNullable = false
                colvarFilename.IsPrimaryKey = false
                colvarFilename.IsForeignKey = false
                colvarFilename.IsReadOnly = false
                
                
                schema.Columns.Add(colvarFilename)
                
                Dim colvarAlbum As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarAlbum.ColumnName = "Album"
                colvarAlbum.DataType = DbType.Int32
                colvarAlbum.MaxLength = 0
                colvarAlbum.AutoIncrement = false
                colvarAlbum.IsNullable = false
                colvarAlbum.IsPrimaryKey = false
                colvarAlbum.IsForeignKey = false
                colvarAlbum.IsReadOnly = false
                
                
                schema.Columns.Add(colvarAlbum)
                
                Dim colvarTitle As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarTitle.ColumnName = "Title"
                colvarTitle.DataType = DbType.String
                colvarTitle.MaxLength = 50
                colvarTitle.AutoIncrement = false
                colvarTitle.IsNullable = false
                colvarTitle.IsPrimaryKey = false
                colvarTitle.IsForeignKey = false
                colvarTitle.IsReadOnly = false
                
                
                schema.Columns.Add(colvarTitle)
                
				BaseSchema = schema
				
				'add this schema to the provider
                'so we can query it later
                DataService.Providers("ClubStarterKitData").AddSchema("TempImagesFile",schema)
			End If
		End Sub
		Public Shared Function CreateQuery() As Query
			Return New Query(Schema)
		End Function
		
		#End Region
		
		#Region "Props"
	
          
        <XmlAttribute("Id")> _
        Public Property Id As Integer 
			Get
				Return GetColumnValue(Of Integer)("ID")
			End Get
		    
			Set
				SetColumnValue("ID", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Filename")> _
        Public Property Filename As String 
			Get
				Return GetColumnValue(Of String)("Filename")
			End Get
		    
			Set
				SetColumnValue("Filename", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Album")> _
        Public Property Album As Integer 
			Get
				Return GetColumnValue(Of Integer)("Album")
			End Get
		    
			Set
				SetColumnValue("Album", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Title")> _
        Public Property Title As String 
			Get
				Return GetColumnValue(Of String)("Title")
			End Get
		    
			Set
				SetColumnValue("Title", Value)
			End Set
		End Property
		
		
		
		
		#End Region
		
		
			    
	    
		
		
		
		
		
	    
	    'no foreign key tables defined (0)
	    
		
	    
	    'no ManyToMany tables defined (0)
	    
		
		#Region "ObjectDataSource support"
		
		''' <summary>
		''' Inserts a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Insert(ByVal varFilename As String,ByVal varAlbum As Integer,ByVal varTitle As String)
			Dim item As TempImagesFile = New TempImagesFile()
			
            item.Filename = varFilename
            
            item.Album = varAlbum
            
            item.Title = varTitle
            
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		''' <summary>
		''' Updates a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Update(ByVal varId As Integer,ByVal varFilename As String,ByVal varAlbum As Integer,ByVal varTitle As String)
			Dim item As TempImagesFile = New TempImagesFile()
		    
                item.Id = varId
				
                item.Filename = varFilename
				
                item.Album = varAlbum
				
                item.Title = varTitle
				
			item.IsNew = False
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		#End Region
		#Region "Columns Struct"
		Public Structure Columns
			Dim x as Integer
			
            Public Shared Id As String = "ID"
            
            Public Shared Filename As String = "Filename"
            
            Public Shared Album As String = "Album"
            
            Public Shared Title As String = "Title"
            
		End Structure
		#End Region
	End Class
End Namespace
